import {computed} from 'vue'
import {renderFileJump, toF9} from "@/utils";

export function useTable() {
  const infos = computed(() => {
    return (item) => {
      return [
        {
          name: '项目主体', value: <div>
            {
              item?.greenProjectCompanyInfos?.map((sub_item) => {
                return <div>
                  <span
                    onClick={() => toF9(sub_item.companyId)}
                    class="common-link">{sub_item.companyName}
                  </span>
                  <span class="label-tag">{sub_item.province}/{sub_item.city}</span>
                  <span
                    class="label-tag">{sub_item.industryCategory}{sub_item.debtorRating ? '/' + sub_item.debtorRating : ''}
                  </span></div>
              })
            }

          </div>, span: 2
        },
        {
          name: '项目投资总额', value: <div>
            <span class="mr-10px">
              {item.totalInvestmentDisplay ? item.totalInvestmentDisplay + '亿' : '-'}
            </span></div>
        },
        {
          name: '项目资本金', value: <div>
            <span class="mr-10px">
              {item.projectCapitalDisplay ? item.projectCapitalDisplay + '亿' : '-'}
            </span></div>
        },
        {
          name: '拟使用募集资金', value: <div>
            <span class="mr-10px">
              {item.amountForProjectDisplay ? item.amountForProjectDisplay + '亿' : '-'}
            </span></div>
        },
        {
          name: '绿债融资金额', value: <div>
            <span class="mr-10px">
              {item.financingAmountGreenBondsDisplay ? item.financingAmountGreenBondsDisplay + '亿' : '-'}
            </span></div>
        },
        {
          name: '其他融资金额', value: <div>
            <span class="mr-10px">
              {item.financingAmountOthersDisplay ? item.financingAmountOthersDisplay + '亿' : '-'}
            </span></div>
        },
        {
          name: '项目预计总收益', value: <div>
            <span class="mr-10px">
              {item.forecastRevenueTotalDisplay ? item.forecastRevenueTotalDisplay + '%' : '-'}
            </span></div>
        },
        {
          name: '项目建设起始', value: <div>
            <span class="mr-10px">
              {item.startingYear ? item.startingYear + '年' : '-'}
            </span></div>
        },
        {
          name: '项目建设截止', value: <div>
            <span class="mr-10px">
              {item.endYear ? item.endYear + '年' : '-'}
            </span></div>
        },
        {
          name: '项目所属地区', value: <div>
            <span class="mr-10px">
              {item.areaName || '-'}
            </span></div>,
          span: 2
        },
      ];
    };
  });

  const infos2 = computed(() => {
    return (item) => {
      return [
        {
          name: '分类依据', value: item.dimension, span: 2
        },
        {
          name: '一级分类',
          value: <div>
            {item.greenProjectClassification1?.length > 0 ? item.greenProjectClassification1.join('、') : '-'}
          </div>,
          span: 2
        },
        {
          name: '二级分类',
          value: <div>
            {item.greenProjectClassification2?.length > 0 ? item.greenProjectClassification2.join('、') : '-'}
          </div>,
          span: 2
        },
        {
          name: '三级分类',
          value: <div>
            {item.greenProjectClassification3?.length > 0 ? item.greenProjectClassification3.join('、') : '-'}
          </div>,
          span: 2
        },
        {
          name: '四级分类',
          value: <div>
            {item.greenProjectClassification4?.length > 0 ? item.greenProjectClassification4.join('、') : '-'}
          </div>,
          span: 2
        },

      ];
    };
  });

  const infos3 = computed(() => {
    return (item) => {
      return item.greenProjectPerformances?.map((citem) => {
        return {
          name: citem.indicator,
          value: <div>
            {citem.indicatorValue + citem.indicatorUnit}
          </div>,
          span: 2
        }
      })
    };
  });
  return {
    infos,
    infos2,
    infos3
  }
}
